<?php

class QuickToolSendItemAction extends SzAbstractAction
{
    Protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_STRING,
        SzAbstractAction::TYPE_STRING,
        SzAbstractAction::TYPE_INT,
    );

    /**
     * @param $userId
     * @param $itemStr
     * @param $numStr
     * @param $reqTime
     * @return SzResponse
     * @throws SzException
     */
    public function execute($userId,$itemStr,$numStr,$reqTime) {
        GameService::get()->validateMultiRequestTimeDelta($userId, $reqTime);
        $itemArr = explode(',',$itemStr);
        $numArr = explode(',',$numStr);
        foreach ($itemArr as $key=>$value){
            if ($value == ''){
                $itemArr[$key] = 0;
            }
        }

        foreach ($numArr as $key1=>$value1){
            if ($value1 == ''){
                $numArr[$key1] = 0;
            }
        }

        return $this->buildResponse(
            QuickToolService::get()->sendUserItem($userId,$itemArr,$numArr,$reqTime)
        );
    }
}